<template>
  <div class="Kan">
    <Navi :title="'想看'" :flexd="true" />
    <div class="top" v-show="isHas">
      <div class="box">
        <div
          class="item"
          v-for="(item, index) in data"
          :key="index"
          @click="goDetails(item.id, false)"
        >
          <div class="imgbox">
            <img
              class="aimg"
              :src="item.movie.img"
              alt=""
              v-lazy="item.movie.img"
            />
          </div>
          <div class="tit one-text">{{ item.movie.nm }}</div>
          <div class="ri">
            上映日期：{{ item.movie.rt ? item.movie.rt : "不详" }}
          </div>
          <div class="ren one-text">
            演员：{{ item.movie.star ? item.movie.star : "不详" }}
          </div>
          <div class="sum">{{ item.movie.sc }}<span class="fen"> 分</span></div>
        </div>
      </div>
    </div>
    <div class="nav" v-show="isHac">
      <van-empty description="暂无看过内容！" />
    </div>
    <div class="type" v-show="token">
      <van-empty description="请先登录">
        <van-button @click="goLogin()" round type="danger" class="bottom-button">去登录</van-button>
      </van-empty>
    </div>
  </div>
</template>

<script>
import Navi from "../components/Navi.vue";
export default {
  name: "Kan",
  components: {
    Navi,
  },
  data() {
    return {
      data: [],
      isHas: false,
      token: false,
      isHac:false,
    };
  },
  created() {
    let localData = JSON.parse(localStorage.getItem("data3") || "[]");
    

    let loc = JSON.parse(localStorage.getItem("token") || "[]");

    
    if (loc.length === 0) {
      this.data = [];
      this.token = true;
      this.isHas = false;
      this.isHac=false;
    } else if (loc.length !== 0&&localData.length === 0) {
      this.isHas = true;
       this.token = false;
       this.isHac = true;
      return;
    } else {
      this.data = localData;
      this.isHas = true;
      this.token = false;
      this.isHac=false;
    }
  },
  methods: {
    goDetails(id, type) {
      this.$router.push({ name: "Details", params: { id, type } });
    },
    goLogin(){
      this.$router.push({ name: "Login" });
    }
  },
};
</script>

<style lang="less" scoped>
.top {
  width: 96%;
  background-color: #fff;
  margin: 0 auto;
  border-radius: 10px;
  .title {
    margin-left: 10px;
    line-height: 50px;
    font-size: 18px;
    font-weight: bold;
    color: #333;
  }
}
.box {
  width: 96%;
  display: flex;
  justify-content: space-between;
  flex-flow: wrap;
  margin: 0 auto;
  padding: 0px 5px 5px;
}
.item {
  width: 48%;
  margin-bottom: 10px;
  border-radius: 10px;
  background-color: #fcfafa;
  overflow: hidden;
  padding-bottom: 6px;
  position: relative;
  .imgbox {
    width: 100%;
    .aimg {
      width: 100%;
      display: block;
      height: 235px;
    }
  }
  .tit {
    width: 100%;
    font-size: 17px;
    color: #444;
    font-weight: bold;
    margin: 7px 0;
  }
  .ren,
  .ri {
    font-size: 13px;
    color: #444;
    font-weight: bold;
    margin-bottom: 7px;
  }
  .sum {
    position: absolute;
    right: 5px;
    bottom: 100px;
    color: #faaf00;
    font-weight: bold;
    font-size: 15px;
  }
  .fen {
    font-size: 13px;
    font-weight: normal;
  }
  .di {
    width: 100%;
    height: 20px;
    font-size: 12px;
    display: flex;
    justify-content: space-between;
    padding: 5px 10px 20px;
    box-sizing: border-box;
    text-align: center;
    line-height: 20px;
    .di1 {
      display: flex;
      .tou {
        width: 20px;
        height: 20px;
        margin-right: 5px;
      }
      .text {
        width: 66px;
      }
    }
  }
}
</style>